import java.util.Scanner;

public class test19 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n1 = in.nextInt(); // 数组1长度
        int n2 = in.nextInt(); // 数组2长度
        int[] nums1 = new int[n1];
        for (int i = 0; i < n1; i++) {
            nums1[i] = in.nextInt();
        }

        int[] nums2 = new int[n2];
        for (int i = 0; i < n1; i++) {
            nums2[i] = in.nextInt();
        }

        getResult(nums1,nums2);
    }

    public static void getResult(int[] nums1,int[] nums2){
        int[] arr = new int[nums1.length+ nums2.length]; // 最后得到的数组
        int index1 = 0,index2 = 0;
        int flag = 0;
        while (index1< nums1.length&&index2< nums2.length){
            if(nums1[index1]<=nums2[index2]) {
                arr[flag] = nums1[index1];
                index1++;
            }
            else {
                arr[flag] = nums2[index2];
                index2++;
            }
            flag++;
        }

        // 剩余数处理
        if(index1< nums1.length){
            while (index1< nums1.length){
                arr[flag] = nums1[index1];
                index1++;
                flag++;
            }
        } else if (index2< nums2.length) {
            while (index2< nums2.length){
                arr[flag] = nums2[index2];
                index2++;
                flag++;
            }
        }
        for (int n: arr)
            System.out.print(n+" ");
    }
}
